package com.sc.JDBCPractices.Dao.Mapper;

import com.sc.JDBCPractices.domain.Stu;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface StuDAOByMybatis  {
    //根据id
    @Select("select * from stu where id=#{id}")
    public Stu findById(@Param("id") long id );
    //查询所有
    @Select("select * from stu ")
    public List<Stu> findAll();
    //根据name
    @Select("select * from stu where username=#{name}")
    public Stu findByName(@Param("name") String username );
    //添加信息
    @Insert("insert into stu (USERNAME, PASS,JAVA,MATH,OS) VALUES(#{username},#{pass}," +
            "#{java},#{math},#{os});")
    int addMes (Stu stu);
    //删除信息
    @Delete("delete from stu where username =#{username};")
    int deleteByName (@Param("username") String username);


}